#include "task.h"
#include <asm-generic/socket.h>
#include <iostream>
#include <liburing.h>
#include <sys/socket.h>
#include <unistd.h>

int main() {
  io_uring ring;
  io_uring_queue_init(32, &ring, 0);

  auto sqe = io_uring_get_sqe(&ring);

  io_uring_prep_socket(sqe, AF_INET, SOCK_STREAM, 0, 0);
  io_uring_submit(&ring);

  io_uring_cqe *cqe;
  io_uring_wait_cqe(&ring, &cqe);

  std::cout << cqe->res << std::endl;

  int fd = cqe->res;

  io_uring_cqe_seen(&ring, cqe);

  int opt = 1;

  co_async::check_error(
      setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt)));

  io_uring_queue_exit(&ring);
}